<include file="public@header"/>
</head>
<body>
    <style type="text/css">
        .lay-ext-mulitsel .layui-input.multiple a{
            line-height: 17px;
        }
    </style>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">添加字段</a></li>
        <li><a href="{:url('arctype/channel_index',array('id'=>$field.id))}">字段列表</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form margin-top-20 layui-form layui-form-pane" action="">
        <div class="form-group">
            <label for="input-full_url" class="col-sm-2 control-label">字段标题<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" lay-verify="required" id="input-full_url" name="title" placeholder="请输入字段标题">
            </div>
        </div>
        <div class="form-group">
            <label for="input-url" class="col-sm-2 control-label">字段名称<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" lay-verify="required" id="input-url" name="name" placeholder="请输入字段名称">
            </div>
        </div>
        <div class="form-group">  
            <label for="input-url" class="col-sm-2 control-label">数值类型<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10">
                <div class="layui-inline">
                    <div>
                        <volist name="typelist" id="vo">
                            <input type="radio" name="field_id" id="channel" value="{$vo.id}" title="{$vo.title}" lay-filter="ChoiceRadio">
                        </volist>
                    </div>
                </div>
            </div>
        </div>

        
        <div class="form-group">
            <label for="input-url" class="col-sm-2 control-label" >默认值<span style="display: none;" id="dfva" class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10">
                <textarea class="form-control" type="text" name="dfvalue" id="source" placeholder="请输入默认值"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label for="input-url" class="col-sm-2 control-label">指定栏目</label>
            <div class="col-md-6 col-sm-10">
                <div class="layui-form-item">
                    <div id="tag_ids">
              
                    </div>
              </div> 
            </div>
        </div>
        <input type="hidden" class="form-control" name="channel_id" value="{$field.id}">
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <!-- <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button> -->
                <button type="button" class="layui-btn" lay-submit="" lay-filter="consub">{:lang('SAVE')}</button>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript" src="__STATIC__/js/admin.js"></script>

<script>
    layui.use(['form','jquery'],function(){
        var form = layui.form;
        $('input:radio[name=field_id]')[0].checked = true;
        form.on('radio(ChoiceRadio)', function(data){
            if (data.value == 8) {
                $('#dfva').css('display','inline-block');
                $('#source').attr('placeholder','如果定义字段类型为下拉框、单选项、多选项时，此处填写被选择的项目(用“,”分开，如“小明,小红,小绿”)。');
            }else{
                $('#dfva').css('display','none');
                $('#source').attr('placeholder','请输入默认值');
            }
        })
        //刷新界面 所有元素
        form.render();
    });
    $(function () {
        var url = "{:url('arctype/catlist')}";
        var posturl = "{:url('arctype/channel_add')}";
        var id = "{$field.id}";
        var tagData = new Array();
        $.get(url,{temp_ip:id},function(result){
            $.each(result.data,function(i,temp){
                if (temp !== undefined) {
                    tagData.push({name: temp.name, id: temp.id})
                     $.each(temp.arr,function(j,temps){
                        if (temps !== undefined) {
                            tagData.push({name: temps.name, id: temps.id})
                        }
                    });
                }
            });
            layui.config({
                base : '/'
            }).extend({
                selectN: './__TMPL__/public/assets/simpleboot3/js/layui/layui_extends/selectN',
                selectM: './__TMPL__/public/assets/simpleboot3/js/layui/layui_extends/selectM',
            }).use(['layer','form','jquery','selectN','selectM'],function(){
                $ = layui.jquery;   
                var form = layui.form,
                selectN = layui.selectN,
                selectM = layui.selectM;
            
                //多选标签-所有配置
                var tagIns2 = selectM({
                    //元素容器【必填】
                    elem: '#tag_ids',
                    //候选数据【必填】
                    data: tagData,
                    //默认值
                    selected: [12],            
                    //最多选中个数，默认5,
                    max : 12,
                    //input的name 不设置与选择器相同(去#.),
                    name: 'cat_id',
                    //值的分隔符
                    delimiter: ',',
                    //候选项数据的键名
                    field: {idName:'id',titleName:'name'},
                });
         
                LayuiPost(posturl);

          });
        },"json");
    })

    

    
      
 


 

    

</script>
</body>
</html>